@extends('backend::layout')

@section('title', '心理健康记录列表')

@section('content')
    <div class="card border-no">
        <div class="card-body">
            <form method="get">
                <div class="row">
                    <div class="clearfix"></div>
                    <div class="col-md-10 col-sm-10 col-xs-10">
                        <label class="col-md-2 col-sm-12">
                            <select class="form-control" id="agency" name="ma_code">
                                <option value="">--类型--</option>
                                @foreach($masters as $val)
                                    <option value="{{ $val->ma_code }}" @if(isset($query['ma_code']) && $query['ma_code'] == $val->ma_code) selected @endif>{{ $val->title }}</option>
                                @endforeach
                            </select>
                        </label>

{{--                        <label class="col-md-2 col-sm-12">--}}
{{--                            <select class="form-control" id="agency" name="g_code">--}}
{{--                                <option value="">--年级--</option>--}}
{{--                                @foreach($grades as $key=>$val)--}}
{{--                                    <option value="{{ $key }}" @if(isset($query['g_code']) && $query['g_code'] == $key) selected @endif >{{ $val }}</option>--}}
{{--                                @endforeach--}}
{{--                            </select>--}}
{{--                        </label>--}}
                        @if(!empty($classes))
                        <label class="col-md-2 col-sm-12">
                            <select class="form-control" id="agency" name="c_code">
                                <option value="">--班级--</option>
                                @foreach($classes as $val)
                                    <option value="{{ $val->c_code }}" @if(isset($query['c_code']) && $query['c_code'] == $val->c_code) selected @endif>{{ $val->name }}</option>
                                @endforeach
                            </select>
                        </label>
                        @endif
                        @if(!empty($students))
                        <label class="col-md-2 col-sm-12" style="box-sizing: content-box">
                            <select class="selectpicker" title="--学生--" name="s_code" data-live-search="true">
                                @foreach($students as $val)
                                    <option value="{{ $val->s_code }}" @if(isset($query['s_code']) && $query['s_code'] == $val->s_code) selected @endif>{{ $val->name }} ({{ $val->class->name }})</option>
                                @endforeach
                            </select>
                        </label>
                        @endif
                        <style>
                            .btn-light {border:1px solid #ced4da;color:#495057!important;background:#fff;margin-right: 10px}
                        </style>

                        <label class="col-md-2 col-sm-12">
                            <button class="btn btn-primary btn-sm">搜索</button>
                        </label>
                    </div>
                    @if($currentAdmin->allow('master/export') && !empty($list))
                        <div class="col-md-2 col-sm-2 col-xs-2">
                            <p class=" pull-right">
                                <a href="
                            {{ route('admin.master.export') }}?
                            @if(!empty($query['m_code'])) m_code={{$query['m_code']}}& @endif
                            @if(!empty($query['g_code'])) g_code={{$query['g_code']}}& @endif
                            @if(!empty($query['c_code'])) c_code={{$query['c_code']}}& @endif
                            " target="_blank" class="btn btn-primary btn-sm">导出当前 {{$list->total()}} 条记录到Excel</a>
                            </p>
                        </div>
                    @endif
                </div>
            </form>
            <h4 class="text-black f-20"></h4>
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th scope="col">#</th>
                        <th scope="col">类型</th>
                        <th scope="col">年级</th>
                        <th scope="col">班级</th>
                        <th scope="col">学生</th>
                        <th scope="col">指数</th>
                        <th scope="col">记录日期</th>
{{--                        <th scope="col">{{ __('Options') }}</th>--}}
                    </tr>
                    </thead>
                    <tbody>
                    @if(isset($list))
                        @foreach($list as $idx => $item)
                            <tr>
                                <th scope="row">{{ $idx + 1 }}</th>
                                <td>{{ $item->master->title }}</td>
                                <td>{{ $item->grade }}</td>
                                <td>{{ $item->class->name }}</td>
                                <td>{{ $item->student->name }}</td>
                                <td>{{ $item->indicators }}</td>
                                <td>{{ $item->record_date }}</td>
{{--                                <td>--}}
{{--                                    @if( $currentAdmin->allow('mental/edit'))--}}
{{--                                        <a href="{{ route('admin.mental.edit', ['id' => $item->id]) }}" class="text-info" title="{{ __('Edit') }}">&nbsp;&nbsp;<i class="fa fa-pencil"></i></a>--}}
{{--                                    @endif--}}
{{--                                    @if($currentAdmin->allow('mental/delete'))--}}
{{--                                        <a href="{{ route('admin.mental.delete', ['id' => $item->id]) }}" class="text-danger confirm-delete" title="{{ __('Delete') }}">&nbsp;&nbsp;<i class="fa fa-trash-o"></i></a>--}}
{{--                                    @endif--}}
{{--                                </td>--}}
                            </tr>
                        @endforeach
                    @endif
                    </tbody>
                </table>
            </div>
            <div class="row">
                <div class="clearfix"></div>
                <div class="col-md-12 col-sm-12 col-xs-12 pull-right">
                    @if(isset($list))
                        {{ $list->links() }}
                    @endif
                </div>
            </div>
        </div>
    </div>
@stop
